﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DB_NH.DB_Map.ZJCQ
{
    using NHibernate;
    using NHibernate.Mapping.ByCode;
    using NHibernate.Mapping.ByCode.Conformist;

    using DB_NH.DB_Model.ZJCQ;

    class ZJ_extract_bak_map : EntityMapping<ZJ_extract_bak>
    {
        public ZJ_extract_bak_map()
        {
            Property(x => x.title, map =>
            {
                map.Length(400);
                map.Column(ZJ_extract_bak.Columns.title);
            });

            //与抽取用户关联纪录
            ManyToOne(x => x.user, map =>
            {
                map.Column(ZJ_extract_bak.Columns.user_id);
                map.NotNullable(false);
            });

            //与抽取详细记录关联
            Bag(x => x.details,
                map =>
                {
                    map.Key(km => km.Column(ZJ_extract_detail_bak.Columns.extract_bak_id));
                },
                act => act.OneToMany());


            //关联项目与抽取关联记录
            Bag(x => x.zj_extract_bak_projects,
                map =>
                {
                    map.Key(km => km.Column("proj_id"));
                },
                act => act.ManyToMany());

            Table(ZJ_extract_bak.TableName);
        }
    }
}
